#include <iostream>
#include <algorithm>
#include <vector>
#define l first
#define r second
using namespace std;
typedef pair<int, int> PII;
const int N = 110;
int l, m;
PII a[N];
vector<PII> v;

int main()
{
    cin >> l >> m;
    ++l;
    for (int i = 0; i < m; ++i)
        cin >> a[i].l >> a[i].r;
    sort(a, a + m);
    v.push_back(a[0]);
    for (int i = 1; i < m; ++i)
    {
        PII &bk = v.back();
        if (a[i].l - 1 <= bk.r)
            bk.r = max(bk.r, a[i].r);
        else
            v.push_back(a[i]);
    }
    int ans = 0;
    for (auto &[l, r] : v)
        ans += r - l + 1;
    cout << (l - ans) << endl;
    return 0;
}
